package com.googlecode.restitory.gae.filter.wrapper;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

public class HttpServletRequestRename extends HttpServletRequestWrapper {

	private String path;
	private final HttpServletRequest req;
	private String method;

	public HttpServletRequestRename(HttpServletRequest request, String path) {
		this(request);
		this.path = path;
	}

	public HttpServletRequestRename(HttpServletRequest request) {
		super(request);
		this.req = request;
	}

	@Override
	public String getRequestURI() {
		if (path == null) {
			return req.getRequestURI();
		}
		return path;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	@Override
	public String getMethod() {
		if (method == null) {
			return req.getMethod();
		}
		return method;
	}

	public void setMethod(String method) {
		this.method = method;
	}

}
